package com.ruoyi.common.utils;

/**
 * 处理并记录日志文件
 * 
 * @author ruoyi
 */
public class LogUtils
{
    public static String getBlock(Object msg)
    {
        if (msg == null)
        {
            msg = "";
        }
        return "[" + msg.toString() + "]";
    }

    /**
     * 获取当前方法调用的类名+方法+代码行
     * @return
     */
    public static  String  getLog(String msg){
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        StackTraceElement log = null;
        boolean findNext = false;
        for(StackTraceElement tmp : stackTrace){
            if(findNext && log == null){
                log = tmp;
                break;
            }
            if("recordLog".equals(tmp.getMethodName())){
                findNext = true;
            }
        }
        String tag = log.getClassName() + " [" + log.getMethodName()+","+log.getLineNumber()+"] "+msg;
        return tag;
    }
}
